//app.js
require("./beforeLaunch.js");

App({

  globalData: {
    userInfo: null
  },

  onLaunch: function () {
    // 配置App
    this.configApp();
    this.login();

  },

  onHide: function() {
    wx.sendFormId();
  },


  configApp: function () {
    let { autoStoreData } = wx.shareData;

    if (autoStoreData) {
      wx.autoManageStoreData();
    }

  },


/**
 * 登录
 */
  login:function(){

    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
        if (wx.collectLoginData("code", res.code)) {
        wx.shareInst.Api.login();
      }
  },
      fail: err => {
      }
    });
  },

})